package com.example.administrator.xjscc;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/12/25.
 */

public class RoadStatusActivity extends Activity {
    private ListView lv_road;
    private List<Map<String,Object>> lst_road=new ArrayList<Map<String,Object>>();
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_roadstatus);

        lv_road=(ListView)findViewById(R.id.lv_road);
        InitData();
    }
    private void InitData()
    {
        for(int i=0;i<5;i++)
        {
            HashMap<String,Object> map=new HashMap<>();
            map.put("road","road"+i);
            map.put("capacity",30);
            map.put("now",5);
            map.put("remain",30-5);
            lst_road.add(map);
        }

        SimpleAdapter ada=new SimpleAdapter(this,lst_road,R.layout.roaditem,
                new String[]{"road","capacity","now","remain"},
                new int[]{R.id.tv_road,R.id.tv_capacity,R.id.tv_now,R.id.tv_remain});
        lv_road.setAdapter(ada);
    }
}
